package cn.dt70.service.impl;

import cn.dt70.dao.aqbOrder.AqbOrderMapper;
import cn.dt70.pojo.AqbOrder;
import cn.dt70.service.AqbOrderService;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class AqbOrderServiceImpl implements AqbOrderService {

    private static final Logger LOGGER = Logger.getLogger(AqbOrderServiceImpl.class);

    @Resource
    private AqbOrderMapper aqbOrderMapper;

    @Override
    public List<AqbOrder> getAllOrder(int id, int start, int end) {
        List<AqbOrder> aqbOrderList =new ArrayList<AqbOrder>();
        try {
            aqbOrderList =  aqbOrderMapper.getAllOrder(id,start,end);
            if(aqbOrderList.size() <= 0){
                LOGGER.debug("AqbOrderServiceImpl 查询为空!");
            }else{
                LOGGER.debug("AqbOrderServiceImpl 查询成功!");
            }
        }catch (Exception e) {
            //e.printStackTrace();
            LOGGER.error("AqbOrderServiceImpl >>>"+e.getMessage());
        }

        return aqbOrderList;
    }

    @Override
    public int getOrderCountbyId(int id) {
        int count = 0;
        try {
            count = aqbOrderMapper.getOrderCountbyId(id);

        }catch (Exception e) {
            //e.printStackTrace();
            LOGGER.error("AqbOrderServiceImpl >>>"+e.getMessage());
        }

        return count;
    }

    @Override
    public List<AqbOrder> getAllOrder2(int id, int start, int end) {
        List<AqbOrder> aqbOrderList =new ArrayList<AqbOrder>();
        try {
            aqbOrderList =  aqbOrderMapper.getAllOrder2(id,start,end);
            if(aqbOrderList.size() <= 0){
                LOGGER.debug("AqbOrderServiceImpl 查询为空!");
            }else{
                LOGGER.debug("AqbOrderServiceImpl 查询成功!");
            }
        }catch (Exception e) {
            //e.printStackTrace();
            LOGGER.error("AqbOrderServiceImpl >>>"+e.getMessage());
        }

        return aqbOrderList;
    }

    @Override
    public List<AqbOrder> getAllOrder3(int id, int start, int end) {
        List<AqbOrder> aqbOrderList =new ArrayList<AqbOrder>();
        try {
            aqbOrderList =  aqbOrderMapper.getAllOrder3(id,start,end);
            if(aqbOrderList.size() <= 0){
                LOGGER.debug("AqbOrderServiceImpl 查询为空!");
            }else{
                LOGGER.debug("AqbOrderServiceImpl 查询成功!");
            }
        }catch (Exception e) {
            //e.printStackTrace();
            LOGGER.error("AqbOrderServiceImpl >>>"+e.getMessage());
        }

        return aqbOrderList;
    }



    @Override
    public Boolean addOrderById(AqbOrder aqbOrder) {
        int flag = 0;
        try {
           flag = aqbOrderMapper.addOrderById(aqbOrder);
        }catch (Exception e) {
            //e.printStackTrace();
            LOGGER.error("addOrderById(AqbOrder aqbOrder)>>>"+e.getMessage());
        }
       if(flag>0){
           return true;
       }else {
           return false;
       }


    }


}
